'''
Created on Apr 20, 2012

@author: root
'''

# All Operations relating to the Hadoop Storage
# Leverages Filesystem, Disk, and Node Object
from Base import Base
#import threading
import Queue


class NodeInfo(Base):
   
    Users = []
    Nodes = [] 
    Disks = []
    returnQueue2 = Queue.Queue()

    def GetNameNode(self):
        namenodes = []
        for node in self.Nodes:
            if ("n" in str(node.personalities)):
                namenodes.append(node)
        return namenodes
    
    def GetSecondaryNameNodes(self):
        secondarys = []
        for node in self.Nodes:
            if ("s" in str(node.personalities)):
                secondarys.append(node)
        return secondarys
            
    def GetJobTracker(self):
        jobtrackers = []
        for node in self.Nodes:
            if ("j" in str(node.personalities)):
                jobtrackers.append(node)
        return jobtrackers
   
    def GetTaskTrackers(self):
        tasktrackers = []
        for node in self.Nodes:
            if ("t" in str(node.personalities)):
                tasktrackers.append(node)
        return tasktrackers
        
        
    def GetDataNodes(self):
        datanodes = []
        for node in self.Nodes:
            if ("d" in str(node.personalities)):
                datanodes.append(node)
        return datanodes
   
    def GetMetadNodes(self):
        metadNodes = []
        for node in self.Nodes:
            if ("metad" in str(node.personalities)):
                metadNodes.append(node)
        return metadNodes    
    
    def GetMondNodes(self):
        mondNodes = []
        for node in self.Nodes:
            if ("mond" in str(node.personalities)):
                mondNodes.append(node)
        return mondNodes    
    
    def GetNodes(self,nodeType):
        
        ''' Check for Role.name ''' #EVENTRUALLY
        
        nodeList = []
        for node in self.Nodes:
            if (str(nodeType) in str(node.personalities)):
                nodeList.append(node)
        return nodeList
    
    
   

    def __init__(self,Nodes,Users):
       self.Users = Users
       self.Nodes = Nodes
       Base.__init__(self)
      
       self.SetUsers(self.Users)
        